home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 676-700 / 681 / term / source.lha / DialPanel.c < prev    next >
C/C++ Source or Header  |  1992-05-09  |  31KB  |  1,324 lines

  1. /*
  2. **    $Id: DialPanel.c,v 1.8 92/05/08 20:50:02 olsen Sta Locker: olsen $
  3. **    $Revision: 1.8 $
  4. **    $Date: 92/05/08 20:50:02 $
  5. **
  6. **    The dialing routine as called by the phonebook
  7. **
  8. **    Copyright © 1990-1992 by Olaf `Olsen' Barthel & MXM
  9. **        All Rights Reserved
  10. */
  11.  
  12. #include "termGlobal.h"
  13.  
  14.     /* Dimensions of the panel window. */
  15.  
  16. #define WIDTH        458
  17. #define HEIGHT        95
  18.  
  19.     /* Some layout assistance. */
  20.  
  21. #define GADGET_WIDTH    (13 * 8)
  22. #define GADGET_COUNT    4
  23. #define GADGET_SPACE    (GADGET_WIDTH + ((WIDTH - 20) - (GADGET_COUNT * GADGET_WIDTH)) / (GADGET_COUNT - 1))
  24.  
  25.     /* Panel gadget IDs. */
  26.  
  27. enum    {    GAD_SKIP,GAD_REMOVE,GAD_ONLINE,GAD_ABORT };
  28.  
  29. UBYTE LineOffset[8] = { 20,28,36,0,50,58,0,72 };
  30.  
  31.     /* CreateAllGadgets():
  32.      *
  33.      *    Create all gadgets required by the dial panel.
  34.      */
  35.  
  36. STATIC struct Gadget *
  37. CreateAllGadgets(struct Gadget **GadgetArray,struct Gadget **GadgetList,APTR VisualInfo,UWORD TopEdge)
  38. {
  39.     struct Gadget        *Gadget;
  40.     struct NewGadget     NewGadget;
  41.     UWORD             Counter = 0;
  42.  
  43.     memset(&NewGadget,0,sizeof(struct NewGadget));
  44.  
  45.     if(Gadget = CreateContext(GadgetList))
  46.     {
  47.         NewGadget . ng_Height        = 12;
  48.         NewGadget . ng_GadgetText    = LocaleString(MSG_DIALPANEL_SKIP_GAD);
  49.         NewGadget . ng_Width        = GADGET_WIDTH;
  50.         NewGadget . ng_TextAttr        = &DefaultFont;
  51.         NewGadget . ng_VisualInfo    = VisualInfo;
  52.         NewGadget . ng_GadgetID        = Counter;
  53.         NewGadget . ng_LeftEdge        = 10;
  54.         NewGadget . ng_Flags        = 0;
  55.         NewGadget . ng_TopEdge        = HEIGHT - 3 - NewGadget . ng_Height;
  56.  
  57.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  58.             GT_Underscore,    '_',
  59.         TAG_DONE);
  60.  
  61.         NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_REMOVE_GAD);
  62.         NewGadget . ng_GadgetID        = Counter;
  63.         NewGadget . ng_LeftEdge        = NewGadget . ng_LeftEdge + GADGET_SPACE;
  64.  
  65.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  66.             GT_Underscore,    '_',
  67.         TAG_DONE);
  68.  
  69.         NewGadget . ng_GadgetText    = LocaleString(MSG_DIALPANEL_GO_TO_ONLINE_GAD);
  70.         NewGadget . ng_GadgetID        = Counter;
  71.         NewGadget . ng_LeftEdge        = NewGadget . ng_LeftEdge + GADGET_SPACE;
  72.  
  73.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  74.             GT_Underscore,    '_',
  75.         TAG_DONE);
  76.  
  77.         NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_ABORT_GAD);
  78.         NewGadget . ng_GadgetID        = Counter;
  79.         NewGadget . ng_LeftEdge        = NewGadget . ng_LeftEdge + GADGET_SPACE;
  80.  
  81.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  82.             GT_Underscore,    '_',
  83.         TAG_DONE);
  84.     }
  85.  
  86.     return(Gadget);
  87. }
  88.  
  89.     /* PrintInfo(struct Window *SomeWindow,WORD X,WORD Y,BYTE *String,...):
  90.      *
  91.      *    Print a string at a given position into the panel window.
  92.      */
  93.  
  94. STATIC VOID __stdargs
  95. PrintInfo(struct Window *SomeWindow,WORD Y,BYTE *String,...)
  96. {
  97.     va_list    VarArgs;
  98.     BYTE    FgPen = SomeWindow -> RPort -> FgPen;
  99.  
  100.     va_start(VarArgs,String);
  101.     VSPrintf(SharedBuffer,String,VarArgs);
  102.     va_end(VarArgs);
  103.  
  104.     SetAPen(SomeWindow -> RPort,0);
  105.     RectFill(SomeWindow -> RPort,86,LineOffset[Y] - 6,78 + 360 - 1 - 3,LineOffset[Y] + 1);
  106.     SetAPen(SomeWindow -> RPort,FgPen);
  107.  
  108.     Move(SomeWindow -> RPort,86,LineOffset[Y]);
  109.     Text(SomeWindow -> RPort,SharedBuffer,strlen(SharedBuffer));
  110. }
  111.  
  112. STATIC VOID __regargs
  113. PrintText(struct Window *Window,WORD Y,UBYTE *String)
  114. {
  115.     Move(Window -> RPort,10,LineOffset[Y]);
  116.     Text(Window -> RPort,String,strlen(String));
  117. }
  118.  
  119.     /* DialPanel():
  120.      *
  121.      *    This routine opens a small window in the middle of the
  122.      *    console window and walks down the list of numbers to
  123.      *    dial.
  124.      */
  125.  
  126. BYTE
  127. DialPanel()
  128. {
  129.     STATIC WORD         PositionX = -1,
  130.                  PositionY = -1;
  131.  
  132.     struct Gadget        *GadgetList = NULL;
  133.     struct Gadget        *GadgetArray[GADGET_COUNT];
  134.     struct Window        *PanelWindow;
  135.     struct PhoneNode    *DialNode;
  136.     BYTE             Result = FALSE;
  137.  
  138.     ChosenEntry    = NULL;
  139.  
  140.     BaudBuffer[0]    = 0;
  141.  
  142.         /* We are dialing. */
  143.  
  144.     Status = STATUS_DIALING;
  145.  
  146.         /* Create the gadgets. */
  147.  
  148.     if(CreateAllGadgets(&GadgetArray[0],&GadgetList,VisualInfo,Screen -> WBorTop + Screen -> Font -> ta_YSize + 1))
  149.     {
  150.         if(PositionX == -1)
  151.             PositionX = (Screen -> Width - WIDTH) >> 1;
  152.  
  153.         if(PositionY == -1)
  154.             PositionY = (Screen -> Height - HEIGHT) >> 1;
  155.  
  156.             /* At last, open the window. */
  157.  
  158.         if(PanelWindow = OpenWindowTags(NULL,
  159.             WA_Width,    WIDTH - 1,
  160.             WA_Height,    HEIGHT,
  161.  
  162.             WA_Left,    PositionX,
  163.             WA_Top,        PositionY,
  164.  
  165.             WA_Activate,    TRUE,
  166.             WA_DragBar,    TRUE,
  167.             WA_DepthGadget,    TRUE,
  168.             WA_CloseGadget,    TRUE,
  169.             WA_RMBTrap,    TRUE,
  170.             WA_CustomScreen,Screen,
  171.  
  172.             WA_IDCMP,    IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | BUTTONIDCMP,
  173.  
  174.             WA_Title,    LocaleString(MSG_DIALPANEL_DIALING_TXT),
  175.         TAG_DONE))
  176.         {
  177.             struct IntuiMessage    *Massage;
  178.             ULONG             Class,Code;
  179.             struct Gadget        *Gadget;
  180.             LONG             RedialDelay = 0,DialTimeout,DialRetries,DialAttempt;
  181.             BYTE             Dialing,Terminated = FALSE,BaudWasPending = FALSE;
  182.  
  183.             UBYTE             SomeBuffer[300],ExitString[80];
  184.             BYTE             Pen,RunCount = 0;
  185.  
  186.             UBYTE             NumberBuffer[40],    *NextNumber    = NULL,
  187.                          InitBuffer[80],    *NextInit    = NULL,
  188.                          ExitBuffer[80],    *NextExit    = NULL,
  189.                          PrefixBuffer[80],    *NextPrefix    = NULL;
  190.  
  191.             ExitString[0] = 0;
  192.  
  193.                 /* Determine the colours to use for display. */
  194.  
  195.             switch(Config . ColourMode)
  196.             {
  197.                 case COLOUR_EIGHT:    Pen = 7;
  198.                             break;
  199.  
  200.                 case COLOUR_SIXTEEN:    Pen = 15;
  201.                             break;
  202.  
  203.                 default:        Pen = 1;
  204.                             break;
  205.             }
  206.  
  207.                 /* Make the current one the active one. */
  208.  
  209.             PushWindow(PanelWindow);
  210.  
  211.                 /* Make a backup of the current configuration. */
  212.  
  213.             CopyMem(&Config,&PrivateConfig,sizeof(struct Configuration));
  214.  
  215.                 /* Add the gadgets and refresh them. */
  216.  
  217.             AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
  218.             RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
  219.             GT_RefreshWindow(PanelWindow,NULL);
  220.  
  221.                 /* Print some information into the
  222.                  * panel window.
  223.                  */
  224.  
  225.             SetAPen(PanelWindow -> RPort,Pen);
  226.  
  227.             DrawBevelBox(PanelWindow -> RPort,82,12,364,28,
  228.                 GTBB_Recessed,    TRUE,
  229.                 GT_VisualInfo,    VisualInfo,
  230.             TAG_DONE);
  231.  
  232.             DrawBevelBox(PanelWindow -> RPort,82,42,364,20,
  233.                 GTBB_Recessed,    TRUE,
  234.                 GT_VisualInfo,    VisualInfo,
  235.             TAG_DONE);
  236.  
  237.             DrawBevelBox(PanelWindow -> RPort,82,64,364,12,
  238.                 GTBB_Recessed,    TRUE,
  239.                 GT_VisualInfo,    VisualInfo,
  240.             TAG_DONE);
  241.  
  242.             PrintText(PanelWindow,0,LocaleString(MSG_DIALPANEL_CALLING_TXT));
  243.             PrintText(PanelWindow,1,LocaleString(MSG_DIALPANEL_NUMBER_TXT));
  244.             PrintText(PanelWindow,2,LocaleString(MSG_DIALPANEL_NEXT_TXT));
  245.  
  246.             PrintText(PanelWindow,4,LocaleString(MSG_DIALPANEL_TIMEOUT_TXT));
  247.             PrintText(PanelWindow,5,LocaleString(MSG_DIALPANEL_ATTEMPT_TXT));
  248.  
  249.             PrintText(PanelWindow,7,LocaleString(MSG_DIALPANEL_MESSAGE_TXT));
  250.  
  251.                 /* Don't echo serial output. */
  252.  
  253.             Quiet        = TRUE;
  254.  
  255.                 /* Perform full sequence check. */
  256.  
  257.             FullCheck    = TRUE;
  258.  
  259.                 /* Reset the number of dial attempts. */
  260.  
  261.             DialAttempt    = 0;
  262.  
  263.                 /* Get the first dial list entry. */
  264.  
  265.             DialNode    = (struct PhoneNode *)DialList -> lh_Head;
  266.  
  267.                 /* The big dialing loop, implemented as a goto -> mark
  268.                  * loop rather than one of those classical while .. do
  269.                  * loops.
  270.                  */
  271.  
  272. Dial:            Dialing        = TRUE;
  273.  
  274.                 /* Reset the sequence scanner, the user may have skipped
  275.                  * the previous dial attempt causing the modem to return
  276.                  * `NO CARRIER'. To prevent the dialer from skipping the
  277.                  * next dial entry as well as the previous we have to
  278.                  * flush any data pending on the serial line.
  279.                  */
  280.  
  281.             HandleSerial();
  282.  
  283.             FlowInit();
  284.  
  285.             FullCheck = TRUE;
  286.  
  287.                 /* Now for multiple phone numbers separated
  288.                  * by `|' characters. If `NextNumber' happens
  289.                  * to be zero, we will prepare to extract
  290.                  * the first phone number from the list.
  291.                  * In any other case we will try to obtain
  292.                  * the next number.
  293.                  */
  294.  
  295.             if(NextNumber)
  296.             {
  297.                 NextNumber    = ExtractString(NextNumber,    NumberBuffer,TRUE);
  298.                 NextInit    = ExtractString(NextInit,    InitBuffer,FALSE);
  299.                 NextExit    = ExtractString(NextExit,    ExitBuffer,FALSE);
  300.                 NextPrefix    = ExtractString(NextPrefix,    PrefixBuffer,FALSE);
  301.             }
  302.             else
  303.             {
  304.                 if(DialNode -> Entry)
  305.                 {
  306.                     NextNumber    = ExtractString(DialNode -> Entry -> Number,NumberBuffer,TRUE);
  307.                     NextInit    = ExtractString(DialNode -> Entry -> Config . ModemInit,InitBuffer,FALSE);
  308.                     NextExit    = ExtractString(DialNode -> Entry -> Config . ModemExit,ExitBuffer,FALSE);
  309.                     NextPrefix    = ExtractString(DialNode -> Entry -> Config . DialPrefix,PrefixBuffer,FALSE);
  310.                 }
  311.                 else
  312.                 {
  313.                     NextNumber    = ExtractString(DialNode -> VanillaNode . ln_Name,NumberBuffer,TRUE);
  314.                     NextInit    = ExtractString(Config . ModemInit,InitBuffer,FALSE);
  315.                     NextExit    = ExtractString(Config . ModemExit,ExitBuffer,FALSE);
  316.                     NextPrefix    = ExtractString(Config . DialPrefix,PrefixBuffer,FALSE);
  317.                 }
  318.             }
  319.  
  320.                 /* If DialNode -> Entry is nonzero it has
  321.                  * a configuration attached.
  322.                  */
  323.  
  324.             if(DialNode -> Entry)
  325.             {
  326.                 DialTimeout    = DialNode -> Entry -> Config . DialTimeout;
  327.                 DialRetries    = DialNode -> Entry -> Config . DialRetries;
  328.  
  329.                     /* We will need to change the serial parameters
  330.                      * in order to establish a connection.
  331.                      */
  332.  
  333.                 if(memcmp(&Config,&DialNode -> Entry -> Config,offsetof(struct Configuration,ModemInit)))
  334.                 {
  335.                     BYTE SameDevice = TRUE;
  336.  
  337.                     CopyMem(&DialNode -> Entry -> Config,&Config,offsetof(struct Configuration,ModemInit));
  338.  
  339.                     Config . SerBuffSize = DialNode -> Entry -> Config . SerBuffSize;
  340.  
  341.                         /* Any device name change? */
  342.  
  343.                     if(strcmp(PrivateConfig . SerialDevice,Config . SerialDevice))
  344.                         SameDevice = FALSE;
  345.                     else
  346.                     {
  347.                             /* Handshaking mode changed to RTS/CTS protocol? */
  348.  
  349.                         if((PrivateConfig . Handshaking != HANDSHAKING_RTSCTS && Config . Handshaking == HANDSHAKING_RTSCTS) || PrivateConfig . SerBuffSize != Config . SerBuffSize)
  350.                             SameDevice = FALSE;
  351.                     }
  352.  
  353.                         /* Stop any IO activity. */
  354.  
  355.                     ClearSerial();
  356.  
  357.                         /* No dramatic changes? Simply change the parameters. */
  358.  
  359.                     if(SameDevice)
  360.                     {
  361.                             /* Use new parameters... */
  362.  
  363.                         SetFlags(WriteRequest);
  364.                         SetFlags(ReadRequest);
  365.  
  366.                             /* ...and set them. */
  367.  
  368.                         WriteRequest -> IOSer . io_Command = SDCMD_SETPARAMS;
  369.  
  370.                         DoIO(WriteRequest);
  371.  
  372.                             /* Restart read request. */
  373.  
  374.                         ReadRequest -> IOSer . io_Command    = CMD_READ;
  375.                         ReadRequest -> IOSer . io_Data        = ReadBuffer;
  376.                         ReadRequest -> IOSer . io_Length    = 1;
  377.  
  378.                         SetSignal(0,SIG_SERIAL);
  379.  
  380.                         SendIO(ReadRequest);
  381.                     }
  382.                     else
  383.                     {
  384.                         UBYTE *Error;
  385.  
  386.                         DeleteSerial();
  387.  
  388.                         if(!(Error = CreateSerial()))
  389.                         {
  390.                             if(StripBuffer)
  391.                                 FreeVec(StripBuffer);
  392.  
  393.                             if(!(StripBuffer = (UBYTE *)AllocVec(Config . SerBuffSize,MEMF_ANY)))
  394.                                 Error = LocaleString(MSG_GLOBAL_NO_AUX_BUFFERS_TXT);
  395.                         }
  396.  
  397.                         if(Error)
  398.                         {
  399.                             BlockWindow(PanelWindow);
  400.  
  401.                             MyEasyRequest(PanelWindow,LocaleString(MSG_GLOBAL_TERM_HAS_A_PROBLEM_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT),Error);
  402.  
  403.                             DeleteSerial();
  404.  
  405.                             ReleaseWindow(PanelWindow);
  406.  
  407.                             SerialSet = FALSE;
  408.  
  409.                             goto Quit;
  410.                         }
  411.                         else
  412.                         {
  413.                             if(SerialMessage)
  414.                             {
  415.                                 MyEasyRequest(Window,LocaleString(MSG_GLOBAL_TERM_HAS_A_PROBLEM_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT),SerialMessage);
  416.  
  417.                                 SerialMessage = NULL;
  418.                             }
  419.                         }
  420.                     }
  421.  
  422.                     if(!Terminated)
  423.                     {
  424.                         WaitTime(0,MILLION / 2);
  425.                         SerWrite("\rAT\r",4);
  426.                         WaitTime(0,MILLION / 2);
  427.                     }
  428.  
  429.                         /* Don't reinitialize serial driver in ConfigSetup()! */
  430.  
  431.                     SerialSet = TRUE;
  432.                 }
  433.  
  434.                 if(ExitString[0])
  435.                 {
  436.                     SerialCommand(ExitString);
  437.  
  438.                     WaitTime(0,MILLION / 2);
  439.                 }
  440.  
  441.                 if(InitBuffer[0])
  442.                 {
  443.                     SerialCommand(InitBuffer);
  444.  
  445.                     WaitTime(0,MILLION / 2);
  446.                 }
  447.  
  448.                 strcpy(ExitString,ExitBuffer);
  449.  
  450.                 PrintInfo(PanelWindow,0,DialNode -> Entry -> Name);
  451.  
  452.                 Say(LocaleString(MSG_DIALPANEL_NOW_CALLING_TXT),DialNode -> Entry -> Name);
  453.  
  454.                 strcpy(SomeBuffer,PrefixBuffer);
  455.  
  456.                 PrintInfo(PanelWindow,1,NumberBuffer);
  457.                 strcat(SomeBuffer,NumberBuffer);
  458.             }
  459.             else
  460.             {
  461.                 DialTimeout    = Config . DialTimeout;
  462.                 DialRetries    = Config . DialRetries;
  463.  
  464.                 if(ExitString[0])
  465.                 {
  466.                     SerialCommand(ExitString);
  467.  
  468.                     WaitTime(0,MILLION / 2);
  469.                 }
  470.  
  471.                 strcpy(ExitString,ExitBuffer);
  472.  
  473.                 PrintInfo(PanelWindow,0,LocaleString(MSG_GLOBAL_UNKNOWN_TXT));
  474.  
  475.                 Say(LocaleString(MSG_DIALPANEL_NOW_CALLING_TXT),NumberBuffer);
  476.  
  477.                 strcpy(SomeBuffer,PrefixBuffer);
  478.  
  479.                 PrintInfo(PanelWindow,1,NumberBuffer);
  480.                 strcat(SomeBuffer,NumberBuffer);
  481.             }
  482.  
  483.             if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  484.                 PrintInfo(PanelWindow,2,((struct PhoneNode *)DialNode -> VanillaNode . ln_Succ) -> Entry -> Name);
  485.             else
  486.                 PrintInfo(PanelWindow,2,LocaleString(MSG_GLOBAL_NONE_TXT));
  487.  
  488.             strcat(SomeBuffer,"\r");
  489.  
  490.             PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_DIALING_TXT));
  491.  
  492.                 /* Dial the number. */
  493.  
  494.             SerialCommand(SomeBuffer);
  495.  
  496.                 /* Reset the signal. */
  497.  
  498.             SetSignal(NULL,SIGBREAKF_CTRL_F);
  499.  
  500.             while(!Terminated)
  501.             {
  502.                 if(Dialing)
  503.                 {
  504.                     PrintInfo(PanelWindow,4,"%2ld:%02ld",DialTimeout / 60,DialTimeout % 60);
  505.                     PrintInfo(PanelWindow,5,LocaleString(MSG_DIALPANEL_ATTEMPT_OF_TXT),DialAttempt + 1,DialRetries);
  506.                 }
  507.                 else
  508.                     PrintInfo(PanelWindow,4,"%2ld:%02ld",RedialDelay / 60,RedialDelay % 60);
  509.  
  510.                 WaitTime(0,MILLION / 2);
  511.  
  512.                     /* The following commands are executed each second */
  513.  
  514.                 if((RunCount++) && !Terminated)
  515.                 {
  516.                     RunCount = 0;
  517.  
  518.                         /* Are we dialing or waiting? */
  519.  
  520.                     if(Dialing)
  521.                     {
  522.                             /* No chance, the dial timeout
  523.                              * has elapsed and no connection
  524.                              * was made.
  525.                              */
  526.  
  527.                         if(!(--DialTimeout))
  528.                         {
  529.                             PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_DIAL_ATTEMPT_TIMEOUT_TXT));
  530.  
  531. Skip1:                            WaitTime(0,MILLION / 2);
  532.                             SerWrite("\r",1);
  533.                             WaitTime(0,MILLION / 2);
  534.  
  535.                                 /* Did we dial all the numbers available? */
  536.  
  537.                             if(NextNumber)
  538.                                 goto Dial;
  539.  
  540.                                 /* Is this one the last entry? */
  541.  
  542.                             if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  543.                             {
  544.                                     /* Proceed to the next entry. */
  545.  
  546.                                 DialNode = (struct DialNode *)DialNode -> VanillaNode . ln_Succ;
  547.  
  548.                                 goto Dial;
  549.                             }
  550.                             else
  551.                             {
  552.                                     /* Is this one the last dial
  553.                                      * attempt to be made?
  554.                                      */
  555.  
  556.                                 if(++DialAttempt >= DialRetries)
  557.                                 {
  558.                                     PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  559.  
  560.                                     WakeUp(PanelWindow,TRUE);
  561.  
  562.                                     WaitTime(2,0);
  563.  
  564.                                     Say(LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  565.  
  566.                                     Terminated = TRUE;
  567.                                 }
  568.                                 else
  569.                                 {
  570.                                         /* Get the first list entry. */
  571.  
  572.                                     DialNode = (struct PhoneNode *)DialList -> lh_Head;
  573.  
  574.                                         /* Get the redial delay. */
  575.  
  576.                                     if(DialNode -> Entry)
  577.                                         RedialDelay = 10 * DialNode -> Entry -> Config . RedialDelay;
  578.                                     else
  579.                                         RedialDelay = 10 * Config . RedialDelay;
  580.  
  581.                                         /* No redial delay? Restart dialing... */
  582.  
  583.                                     if(!RedialDelay)
  584.                                     {
  585.                                         WaitTime(1,0);
  586.  
  587.                                         goto Dial;
  588.                                     }
  589.                                     else
  590.                                     {
  591.                                             /* Go into redial delay. */
  592.  
  593.                                         PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_REDIAL_DELAY_TXT));
  594.  
  595.                                         Dialing = FALSE;
  596.  
  597.                                         Say(LocaleString(MSG_DIALPANEL_WAITING_TXT));
  598.                                     }
  599.                                 }
  600.                             }
  601.                         }
  602.                     }
  603.                     else
  604.                     {
  605.                         if(!(--RedialDelay))
  606.                         {
  607.                                 /* Get the first list entry. */
  608.  
  609. Skip2:                            DialNode = (struct PhoneNode *)DialList -> lh_Head;
  610.  
  611.                                 /* We are once again dialing. */
  612.  
  613.                             Dialing = TRUE;
  614.  
  615.                             goto Dial;
  616.                         }
  617.                     }
  618.                 }
  619.  
  620.                     /* Handle serial data flow. */
  621.  
  622.                 HandleSerial();
  623.  
  624.                     /* Something has changed in the flow
  625.                      * info structure.
  626.                      */
  627.  
  628.                 if(FlowInfo . Changed)
  629.                 {
  630.                         /* We had a connect and the
  631.                          * baud rate has been transferred.
  632.                          */
  633.  
  634.                     if(BaudWasPending && !BaudPending)
  635.                     {
  636.                         ULONG Value;
  637.  
  638.                         if(Value = atol(BaudBuffer))
  639.                         {
  640.                             if(DialNode -> Entry)
  641.                                 CopyMem(&DialNode -> Entry -> Config,&Config,sizeof(struct Configuration));
  642.  
  643.                             Config . BaudRate = Value;
  644.                         }
  645.  
  646.                         goto ConnectIt;
  647.                     }
  648.  
  649.                         /* Current number is busy. */
  650.  
  651.                     if(FlowInfo . Busy || FlowInfo . NoCarrier)
  652.                     {
  653.                         FlowInit();
  654.  
  655.                         FullCheck = TRUE;
  656.  
  657.                         FlowInfo . Busy        = FALSE;
  658.                         FlowInfo . NoCarrier    = FALSE;
  659.                         FlowInfo . Changed    = FALSE;
  660.  
  661.                         if(Dialing)
  662.                         {
  663.                             PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_LINE_IS_BUSY_TXT));
  664.  
  665.                             Say(LocaleString(MSG_DIALPANEL_LINE_IS_BUSY_TXT));
  666.  
  667.                             WaitTime(1,0);
  668.  
  669.                             goto Skip1;
  670.                         }
  671.                     }
  672.  
  673.                         /* Line does not feature a dialtone. */
  674.  
  675.                     if(FlowInfo . NoDialTone)
  676.                     {
  677.                         FlowInit();
  678.  
  679.                         PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_NO_DIALTONE_TXT));
  680.  
  681.                         WakeUp(PanelWindow,FALSE);
  682.  
  683.                         WaitTime(1,0);
  684.  
  685.                         Say(LocaleString(MSG_DIALPANEL_NO_DIALTONE_TXT));
  686.  
  687.                         Terminated = TRUE;
  688.                     }
  689.  
  690.                         /* Somebody tries to call us. */
  691.  
  692.                     if(FlowInfo . Ring && !Terminated)
  693.                     {
  694.                         FlowInit();
  695.  
  696.                         PrintInfo(PanelWindow,7,LocaleString(MSG_GLOBAL_INCOMING_CALL_TXT));
  697.  
  698.                         WakeUp(PanelWindow,TRUE);
  699.  
  700.                         WaitTime(1,0);
  701.  
  702.                         Say(LocaleString(MSG_GLOBAL_INCOMING_CALL_TXT));
  703.  
  704.                         Terminated = TRUE;
  705.                     }
  706.  
  707.                         /* Somebody's talking. */
  708.  
  709.                     if(FlowInfo . Voice && !Terminated)
  710.                     {
  711.                         FlowInit();
  712.  
  713.                         PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_INCOMING_VOICE_CALL_TXT));
  714.  
  715.                         WakeUp(PanelWindow,TRUE);
  716.  
  717.                         WaitTime(1,0);
  718.  
  719.                         Say(LocaleString(MSG_DIALPANEL_INCOMING_VOICE_CALL_TXT));
  720.  
  721.                         Terminated = TRUE;
  722.                     }
  723.  
  724.                         /* We got a connect. */
  725.  
  726.                     if(FlowInfo . Connect && !Terminated)
  727.                     {
  728.                         FlowInfo . Connect = FALSE;
  729.                         FlowInfo . Changed = FALSE;
  730.  
  731.                             /* Auto-baud feature enabled?
  732.                              * If yes, wait for the number.
  733.                              */
  734.  
  735.                         if(BaudPending)
  736.                         {
  737.                             if(Config . ConnectAutoBaud)
  738.                                 BaudWasPending = TRUE;
  739.                             else
  740.                                 BaudPending = FALSE;
  741.                         }
  742.  
  743.                             /* Seems that we've received
  744.                              * a number.
  745.                              */
  746.  
  747. ConnectIt:                    if(!BaudPending)
  748.                         {
  749.                                 /* Install the new configuration. */
  750.  
  751.                             if(!BaudWasPending)
  752.                             {
  753.                                 if(DialNode -> Entry)
  754.                                     CopyMem(&DialNode -> Entry -> Config,&Config,sizeof(struct Configuration));
  755.                             }
  756.  
  757.                                 /* Convert the baud rate. */
  758.  
  759.                             if(BaudBuffer[0])
  760.                             {
  761.                                 LONG TestRate = atol(BaudBuffer);
  762.  
  763.                                 if(TestRate >= 110)
  764.                                     Config . BaudRate = TestRate;
  765.                             }
  766.  
  767.                                 /* Reset the scanner. */
  768.  
  769.                             FlowInit();
  770.  
  771.                                 /* Copy the remaining data. */
  772.  
  773.                             if(DialNode -> Entry)
  774.                             {
  775.                                 SelectTime(DialNode -> Entry);
  776.  
  777.                                 ChosenEntry = DialNode -> Entry;
  778.  
  779.                                 CurrentPay    = 0;
  780.  
  781.                                 SendStartup    = TRUE;
  782.  
  783.                                 strcpy(Password,DialNode -> Entry -> Password);
  784.                                 strcpy(UserName,DialNode -> Entry -> UserName);
  785.                             }
  786.                             else
  787.                             {
  788.                                 CurrentPay    = 0;
  789.  
  790.                                 ChosenEntry    = NULL;
  791.  
  792.                                 Password[0]    = 0;
  793.                                 UserName[0]    = 0;
  794.  
  795.                                 SendStartup    = FALSE;
  796.                             }
  797.  
  798.                                 /* We are now online. */
  799.  
  800.                             Online        = TRUE;
  801.                             Terminated    = TRUE;
  802.  
  803.                                 /* Add another logfile entry. */
  804.  
  805.                             if(DialNode -> Entry)
  806.                                 LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_1_TXT),DialNode -> Entry -> Name,NumberBuffer);
  807.                             else
  808.                                 LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_2_TXT),NumberBuffer);
  809.  
  810.                                 /* Open auto-capture file if necessary. */
  811.  
  812.                             if(Config . ConnectAutoCapture && Config . CapturePath[0])
  813.                             {
  814.                                 UBYTE        SharedBuffer[256],Name[50],Date[20];
  815.                                 struct DateTime    DateTime;
  816.  
  817.                                 DateStamp(&DateTime . dat_Stamp);
  818.  
  819.                                 DateTime . dat_Format    = FORMAT_DOS;
  820.                                 DateTime . dat_Flags    = 0;
  821.                                 DateTime . dat_StrDay    = NULL;
  822.                                 DateTime . dat_StrDate    = Date;
  823.                                 DateTime . dat_StrTime    = NULL;
  824.  
  825.                                 strcpy(SharedBuffer,Config . CapturePath);
  826.  
  827.                                 if(DateToStr(&DateTime))
  828.                                 {
  829.                                     if(DialNode -> Entry)
  830.                                     {
  831.                                         WORD i;
  832.  
  833.                                         strcpy(Name,DialNode -> Entry -> Name);
  834.  
  835.                                         for(i = 0 ; i < strlen(Name) ; i++)
  836.                                         {
  837.                                             if(Name[i] == ' ')
  838.                                                 Name[i] = '_';
  839.                                         }
  840.                                     }
  841.                                     else
  842.                                         strcpy(Name,LocaleString(MSG_DIALPANEL_CAPTURE_NAME_TXT));
  843.  
  844.                                     strcat(Name,"_");
  845.                                     strcat(Name,Date);
  846.  
  847.                                     if(AddPart(SharedBuffer,Name,256))
  848.                                     {
  849.                                         struct MenuItem *Item;
  850.  
  851.                                         Item = FindThisItem(MEN_CAPTUREDISK);
  852.  
  853.                                         Item -> Flags &= ~CHECKED;
  854.  
  855.                                         if(FileCapture)
  856.                                         {
  857.                                             BufferClose(FileCapture);
  858.  
  859.                                             if(!GetFileSize(CaptureName))
  860.                                                 DeleteFile(CaptureName);
  861.                                             else
  862.                                                 SetProtection(CaptureName,FIBF_EXECUTE);
  863.                                         }
  864.  
  865.                                         if(FileCapture = BufferOpen(SharedBuffer,"a"))
  866.                                         {
  867.                                             Item -> Flags |= CHECKED;
  868.  
  869.                                             strcpy(CaptureName,SharedBuffer);
  870.                                         }
  871.                                     }
  872.                                 }
  873.                             }
  874.  
  875.                                 /* Remove the node from the
  876.                                  * dialing list.
  877.                                  */
  878.  
  879.                             if(DialNode -> Entry)
  880.                                 RemoveDialNode(DialNode);
  881.  
  882.                             Remove(&DialNode -> VanillaNode);
  883.  
  884.                             FreeVec(DialNode);
  885.  
  886.                                 /* Wake the user up. */
  887.  
  888.                             PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_CONNECTION_ESTABLISHED_TXT));
  889.  
  890.                             WakeUp(PanelWindow,TRUE);
  891.  
  892.                             if(Config . BackupConfig)
  893.                             {
  894.                                 if(!BackupConfig)
  895.                                 {
  896.                                     if(BackupConfig = (struct Configuration *)AllocVec(sizeof(struct Configuration),MEMF_ANY))
  897.                                         memcpy(BackupConfig,&PrivateConfig,sizeof(struct Configuration));
  898.                                 }
  899.                             }
  900.  
  901.                             Say(LocaleString(MSG_DIALPANEL_CONNECTION_ESTABLISHED_TXT));
  902.  
  903.                                 /* Don't process any data until the screen
  904.                                  * is set up correctly.
  905.                                  */
  906.  
  907.                             Blocking = TRUE;
  908.  
  909.                                 /* Perform system initialization. */
  910.  
  911.                             ConfigSetup();
  912.                         }
  913.                     }
  914.                 }
  915.  
  916.                     /* Look for the hotkey. */
  917.  
  918.                 if(SetSignal(NULL,NULL) & SIGBREAKF_CTRL_F)
  919.                 {
  920.                     SetSignal(NULL,SIGBREAKF_CTRL_F);
  921.  
  922.                         /* Are we dialing or waiting? */
  923.  
  924.                     if(Dialing)
  925.                     {
  926.                         DialTimeout = 0;
  927.  
  928.                         goto Skip1;
  929.                     }
  930.                     else
  931.                     {
  932.                         RedialDelay = 0;
  933.  
  934.                         goto Skip2;
  935.                     }
  936.                 }
  937.  
  938.                     /* Pick up the window input. */
  939.  
  940.                 while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
  941.                 {
  942.                     Class    = Massage -> Class;
  943.                     Code    = Massage -> Code;
  944.                     Gadget    = (struct Gadget *)Massage -> IAddress;
  945.  
  946.                     GT_ReplyIMsg(Massage);
  947.  
  948.                     if(Class == IDCMP_VANILLAKEY)
  949.                     {
  950.                         if(Code == ' ')
  951.                         {
  952.                             Class    = IDCMP_GADGETUP;
  953.                             Code    = 0;
  954.                             Gadget    = GadgetArray[GAD_SKIP];
  955.                         }
  956.                         else
  957.                             KeySelect(GadgetArray,GAD_ABORT,Code,PanelWindow,&Gadget,&Class,&Code);
  958.                     }
  959.  
  960.                         /* Close the window, hang up the line. */
  961.  
  962.                     if(Class == IDCMP_CLOSEWINDOW)
  963.                     {
  964.                         Class    = IDCMP_GADGETUP;
  965.                         Gadget    = GadgetArray[GAD_ABORT];
  966.  
  967.                         Result = TRUE;
  968.                     }
  969.  
  970.                     if(Class == IDCMP_GADGETUP)
  971.                     {
  972.                         switch(Gadget -> GadgetID)
  973.                         {
  974.                                     /* Don't proceed to the next number in the buffer! */
  975.  
  976.                             case GAD_REMOVE:NextNumber = NULL;
  977.  
  978.                                     if(Dialing)
  979.                                     {
  980.                                         struct PhoneNode *NextNode = NULL;
  981.  
  982.                                             /* Is there another entry in the list? */
  983.  
  984.                                         if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  985.                                             NextNode = (struct PhoneNode *)DialNode -> VanillaNode . ln_Succ;
  986.                                         else
  987.                                         {
  988.                                                 /* No, there isn't; do we have a list with
  989.                                                  * at least two entries in it?
  990.                                                  */
  991.  
  992.                                             if(DialList -> lh_Head -> ln_Succ -> ln_Succ)
  993.                                             {
  994.                                                     /* There is just a single entry
  995.                                                      * available, check for dial retry
  996.                                                      * limit.
  997.                                                      */
  998.  
  999.                                                 if(++DialAttempt >= DialRetries)
  1000.                                                 {
  1001.                                                     PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  1002.  
  1003.                                                     WakeUp(PanelWindow,TRUE);
  1004.  
  1005.                                                     WaitTime(1,0);
  1006.  
  1007.                                                     Say(LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  1008.  
  1009.                                                     Terminated = TRUE;
  1010.                                                 }
  1011.                                                 else
  1012.                                                 {
  1013.                                                         /* Grab first list entry and continue. */
  1014.  
  1015.                                                     NextNode = (struct PhoneNode *)DialList -> lh_Head;
  1016.                                                 }
  1017.                                             }
  1018.                                             else
  1019.                                             {
  1020.                                                 Terminated = TRUE;
  1021.  
  1022.                                                 PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_DIALING_LIST_IS_EMPTY_TXT));
  1023.  
  1024.                                                 WaitTime(1,0);
  1025.                                             }
  1026.                                         }
  1027.  
  1028.                                         DialTimeout = 0;
  1029.  
  1030.                                         WaitTime(0,MILLION / 2);
  1031.                                         SerWrite("\r",1);
  1032.                                         WaitTime(0,MILLION / 2);
  1033.  
  1034.                                             /* Remove dial entry from list. */
  1035.  
  1036.                                         if(DialNode -> Entry)
  1037.                                             RemoveDialNode(DialNode);
  1038.  
  1039.                                         Remove(&DialNode -> VanillaNode);
  1040.  
  1041.                                         FreeVec(DialNode);
  1042.  
  1043.                                             /* Is there an entry to proceed with? */
  1044.  
  1045.                                         if(NextNode)
  1046.                                         {
  1047.                                             DialNode = NextNode;
  1048.  
  1049.                                             goto Dial;
  1050.                                         }
  1051.                                     }
  1052.                                     else
  1053.                                     {
  1054.                                         struct PhoneNode *LastNode;
  1055.  
  1056.                                             /* We are to leave the redial delay loop,
  1057.                                              * are there at least two entries in
  1058.                                              * the list?
  1059.                                              */
  1060.  
  1061.                                         if(!DialList -> lh_Head -> ln_Succ -> ln_Succ)
  1062.                                         {
  1063.                                                 /* No, there is just a single entry in
  1064.                                                  * the list.
  1065.                                                  */
  1066.  
  1067.                                             Terminated = TRUE;
  1068.  
  1069.                                             PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_DIALING_LIST_IS_EMPTY_TXT));
  1070.  
  1071.                                             WaitTime(0,MILLION / 2);
  1072.                                             SerWrite("\r",1);
  1073.                                             WaitTime(2,MILLION / 2);
  1074.                                         }
  1075.  
  1076.                                             /* Remove last dial entry from list. */
  1077.  
  1078.                                         LastNode = (struct PhoneNode *)DialList -> lh_TailPred;
  1079.  
  1080.                                         if(LastNode -> Entry)
  1081.                                             RemoveDialNode(LastNode);
  1082.  
  1083.                                         Remove(&LastNode -> VanillaNode);
  1084.  
  1085.                                         FreeVec(LastNode);
  1086.  
  1087.                                             /* Get back to first list entry. */
  1088.  
  1089.                                         if(!Terminated)
  1090.                                         {
  1091.                                             RedialDelay = 0;
  1092.  
  1093.                                             goto Skip2;
  1094.                                         }
  1095.                                     }
  1096.  
  1097.                                     break;
  1098.  
  1099.                             case GAD_SKIP:    if(Dialing)
  1100.                                     {
  1101.                                         DialTimeout = 0;
  1102.  
  1103.                                         goto Skip1;
  1104.                                     }
  1105.                                     else
  1106.                                     {
  1107.                                         RedialDelay = 0;
  1108.  
  1109.                                         goto Skip2;
  1110.                                     }
  1111.  
  1112.                                         /* Forced online,
  1113.                                          * install new configuration
  1114.                                          * first.
  1115.                                          */
  1116.  
  1117.                             case GAD_ONLINE:if(DialNode -> Entry)
  1118.                                         CopyMem(&DialNode -> Entry -> Config,&Config,sizeof(struct Configuration));
  1119.  
  1120.                                         /* Copy the remaining information. */
  1121.  
  1122.                                     if(DialNode -> Entry)
  1123.                                     {
  1124.                                         SelectTime(DialNode -> Entry);
  1125.  
  1126.                                         ChosenEntry = DialNode -> Entry;
  1127.  
  1128.                                         CurrentPay    = 0;
  1129.  
  1130.                                         SendStartup    = TRUE;
  1131.  
  1132.                                         strcpy(Password,DialNode -> Entry -> Password);
  1133.                                         strcpy(UserName,DialNode -> Entry -> UserName);
  1134.                                     }
  1135.                                     else
  1136.                                     {
  1137.                                         CurrentPay    = 0;
  1138.  
  1139.                                         ChosenEntry    = NULL;
  1140.  
  1141.                                         Password[0]    = 0;
  1142.                                         UserName[0]    = 0;
  1143.  
  1144.                                         SendStartup    = FALSE;
  1145.                                     }
  1146.  
  1147.                                         /* We are now online. */
  1148.  
  1149.                                     Online        = TRUE;
  1150.                                     Terminated    = TRUE;
  1151.  
  1152.                                         /* Add a new log action. */
  1153.  
  1154.                                     if(DialNode -> Entry)
  1155.                                         LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_1_TXT),DialNode -> Entry -> Name,NumberBuffer);
  1156.                                     else
  1157.                                         LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_2_TXT),NumberBuffer);
  1158.  
  1159.                                         /* Open auto-capture file. */
  1160.  
  1161.                                     if(Config . ConnectAutoCapture && Config . CapturePath[0])
  1162.                                     {
  1163.                                         UBYTE        SharedBuffer[256],Name[50],Date[20];
  1164.                                         struct DateTime    DateTime;
  1165.  
  1166.                                         DateStamp(&DateTime . dat_Stamp);
  1167.  
  1168.                                         DateTime . dat_Format    = FORMAT_DOS;
  1169.                                         DateTime . dat_Flags    = 0;
  1170.                                         DateTime . dat_StrDay    = NULL;
  1171.                                         DateTime . dat_StrDate    = Date;
  1172.                                         DateTime . dat_StrTime    = NULL;
  1173.  
  1174.                                         strcpy(SharedBuffer,Config . CapturePath);
  1175.  
  1176.                                         if(DateToStr(&DateTime))
  1177.                                         {
  1178.                                             if(DialNode -> Entry)
  1179.                                             {
  1180.                                                 WORD i;
  1181.  
  1182.                                                 strcpy(Name,DialNode -> Entry -> Name);
  1183.  
  1184.                                                 for(i = 0 ; i < strlen(Name) ; i++)
  1185.                                                 {
  1186.                                                     if(Name[i] == ' ')
  1187.                                                         Name[i] = '_';
  1188.                                                 }
  1189.                                             }
  1190.                                             else
  1191.                                                 strcpy(Name,LocaleString(MSG_DIALPANEL_CAPTURE_NAME_TXT));
  1192.  
  1193.                                             strcat(Name,"_");
  1194.                                             strcat(Name,Date);
  1195.  
  1196.                                             if(AddPart(SharedBuffer,Name,256))
  1197.                                             {
  1198.                                                 struct MenuItem *Item;
  1199.  
  1200.                                                 Item = FindThisItem(MEN_CAPTUREDISK);
  1201.  
  1202.                                                 Item -> Flags &= ~CHECKED;
  1203.  
  1204.                                                 if(FileCapture)
  1205.                                                 {
  1206.                                                     BufferClose(FileCapture);
  1207.  
  1208.                                                     if(!GetFileSize(CaptureName))
  1209.                                                         DeleteFile(CaptureName);
  1210.                                                     else
  1211.                                                         SetProtection(CaptureName,FIBF_EXECUTE);
  1212.                                                 }
  1213.  
  1214.                                                 if(FileCapture = BufferOpen(SharedBuffer,"a"))
  1215.                                                 {
  1216.                                                     Item -> Flags |= CHECKED;
  1217.  
  1218.                                                     strcpy(CaptureName,SharedBuffer);
  1219.                                                 }
  1220.                                             }
  1221.                                         }
  1222.                                     }
  1223.  
  1224.                                         /* Remove node from
  1225.                                          * dialing list and
  1226.                                          * perform system
  1227.                                          * setup.
  1228.                                          */
  1229.  
  1230.                                     if(DialNode -> Entry)
  1231.                                         RemoveDialNode(DialNode);
  1232.  
  1233.                                     Remove(&DialNode -> VanillaNode);
  1234.  
  1235.                                     FreeVec(DialNode);
  1236.  
  1237.                                     if(Config . BackupConfig)
  1238.                                     {
  1239.                                         if(!BackupConfig)
  1240.                                         {
  1241.                                             if(BackupConfig = (struct Configuration *)AllocVec(sizeof(struct Configuration),MEMF_ANY))
  1242.                                                 memcpy(BackupConfig,&PrivateConfig,sizeof(struct Configuration));
  1243.                                         }
  1244.                                     }
  1245.  
  1246.                                     Blocking = TRUE;
  1247.  
  1248.                                     ConfigSetup();
  1249.  
  1250.                                     break;
  1251.  
  1252.                                 /* Abort the dialing process. */
  1253.  
  1254.                             case GAD_ABORT:    Terminated = TRUE;
  1255.  
  1256.                                     PrintInfo(PanelWindow,7,LocaleString(MSG_DIALPANEL_ABORTING_TXT));
  1257.  
  1258.                                     WaitTime(0,MILLION / 2);
  1259.                                     SerWrite("\r",1);
  1260.                                     WaitTime(0,MILLION / 2);
  1261.  
  1262.                                     break;
  1263.                         }
  1264.                     }
  1265.                 }
  1266.             }
  1267.  
  1268.                 /* Are we perhaps not online? */
  1269.  
  1270. Quit:            if(!Online)
  1271.             {
  1272.                     /* Is the serial setup different? */
  1273.  
  1274.                 if(memcmp(&PrivateConfig,&Config,58))
  1275.                 {
  1276.                         /* Swap the serial data. */
  1277.  
  1278.                     swmem(&PrivateConfig,&Config,58);
  1279.  
  1280.                         /* Set up the old serial configuration. */
  1281.  
  1282.                     ConfigSetup();
  1283.  
  1284.                         /* Reinitialize... */
  1285.  
  1286.                     WaitTime(0,MILLION / 2);
  1287.                     SerWrite("\rAT\r",4);
  1288.                     WaitTime(0,MILLION / 2);
  1289.                 }
  1290.  
  1291.                     /* Do we have a valid modem exit string? */
  1292.  
  1293.                 if(ExitString[0])
  1294.                 {
  1295.                     SerialCommand(ExitString);
  1296.  
  1297.                     WaitTime(0,MILLION / 2);
  1298.                 }
  1299.             }
  1300.  
  1301.                 /* Reset the scanner. */
  1302.  
  1303.             FlowInit();
  1304.  
  1305.             RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
  1306.  
  1307.             PopWindow();
  1308.  
  1309.             PositionX = PanelWindow -> LeftEdge;
  1310.             PositionY = PanelWindow -> TopEdge;
  1311.  
  1312.             CloseWindow(PanelWindow);
  1313.         }
  1314.     }
  1315.  
  1316.     FreeGadgets(GadgetList);
  1317.  
  1318.         /* We are done now, restart echoing serial */
  1319.  
  1320.     Quiet = FALSE;
  1321.  
  1322.     return(Result);
  1323. }
  1324.